# # 定义自定义异常类OopsException，继承自BaseException
# class OopsException(BaseException):
#     pass
#
# # 触发并捕获OopsException异常
# try:
#     # 主动触发自定义异常
#     raise OopsException()
# except OopsException:
#     # 捕获异常后打印指定信息
#     print("Catch an oops")
#
class OopsException(Exception):
    def __init__(self, message):
        self.message = message
        super().__init__(self.message)

try:
    # 触发异常时传入提示信息
    raise OopsException("出现了自定义异常")
except OopsException:
    print("Catch an oops")